import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * uiPageService.js
 * @date 2018/9/29

 */
import request from 'utils/request';
import { CPAAS_PLATFORM } from 'utils/config';
import { parseParameter } from 'utils/utils';
export function uiPageOrgQueryPaging(_x, _x2) {
  return _uiPageOrgQueryPaging.apply(this, arguments);
}

function _uiPageOrgQueryPaging() {
  _uiPageOrgQueryPaging = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(organizationId, params) {
    var query;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            query = parseParameter(params);
            return _context.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/ui-pages"), {
              query: query,
              method: 'GET'
            }));

          case 2:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _uiPageOrgQueryPaging.apply(this, arguments);
}

export function uiPageOrgCreate(_x3, _x4) {
  return _uiPageOrgCreate.apply(this, arguments);
}

function _uiPageOrgCreate() {
  _uiPageOrgCreate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(organizationId, uiPage) {
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            return _context2.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/ui-pages"), {
              body: uiPage,
              method: 'POST'
            }));

          case 1:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _uiPageOrgCreate.apply(this, arguments);
}

export function uiPageOrgUpdate(_x5, _x6) {
  return _uiPageOrgUpdate.apply(this, arguments);
}

function _uiPageOrgUpdate() {
  _uiPageOrgUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(organizationId, uiPage) {
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            return _context3.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/ui-pages"), {
              body: uiPage,
              method: 'PUT'
            }));

          case 1:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));
  return _uiPageOrgUpdate.apply(this, arguments);
}

export function uiPageOrgQueryDetail(_x7, _x8) {
  return _uiPageOrgQueryDetail.apply(this, arguments);
}
/**
 * save page config
 * @param config
 * @returns {Promise<void>}
 */

function _uiPageOrgQueryDetail() {
  _uiPageOrgQueryDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(organizationId, pageCode) {
    return _regeneratorRuntime.wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            return _context4.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/ui-pages/").concat(pageCode), {
              method: 'GET'
            }));

          case 1:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  }));
  return _uiPageOrgQueryDetail.apply(this, arguments);
}

export function uiPageOrgDetailUpdate(_x9, _x10) {
  return _uiPageOrgDetailUpdate.apply(this, arguments);
}

function _uiPageOrgDetailUpdate() {
  _uiPageOrgDetailUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(organizationId, config) {
    return _regeneratorRuntime.wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            return _context5.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/ui-pages/detail"), {
              method: 'PUT',
              body: config
            }));

          case 1:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));
  return _uiPageOrgDetailUpdate.apply(this, arguments);
}